package com.pricl.frame.page.paging;

import com.pricl.frame.page.module.Page;

public class MysqlPagingAdapter implements IPagingAdapter {

	@Override
	public String paging(String sql, Page<?> page) {
		int pageNumber = page.getPageNumber();
		int pageSize = page.getPageSize();

		if (pageNumber > 0 && pageSize > 0) {
			int currRow = (pageNumber - 1) * pageSize;
			StringBuffer pageSql = new StringBuffer();
			pageSql.append(sql);
			pageSql.append(" limit " + currRow + "," + pageSize);
			return pageSql.toString();
		}

		return sql;
	}

}
